import router from '@/router'

export const useInfoStore = defineStore(
  'info',
  () => {
    const activeBar = ref('home')
    const myActive = ref('dynamic')
    const historyList = ref([])
    const chatList = ref([])
    const userInfo = ref(null)

    const logout = () => {
      activeBar.value = 'home'
      historyList.value = []
      chatList.value = []
      userInfo.value = null

      localStorage.clear()
      router.push('/login')
    }

    return { activeBar, myActive, historyList, chatList, userInfo, logout }
  },
  {
    persist: true
  }
)
